EXPT block

Short summary

Name

EXPT

→POU type

→function

Category

IEC-block, Numeric, block with internal error diagnostic

Conform to →IEC-standard

(plus) more possible than defined in IEC-standard;
(IEC demands ANY_REAL for the input IN1 and the return value.)

and

(error) currently restricted
(IEC demands error handling, if the result of the block exceeds the range of values for the output data type. See "No check of invalid connections" for the behavior in Neuron Power Engineer.)

Graphical interface

Available since

  • version 1.0.0 (for Neuron Power Engineer) – initial variant

  • version 2.0.16 (for library Standard) – enhancement: internal error diagnostic, refactoring to guarantee the calculation of correct results for connected ANY_INT values 

  • version 3.1.0 (for library Standard) – For inputs of data type REAL, the optimized float variant of the C-runtime is used. Compared to previous versions, it is possible that (marginal) other results are returned within the threshold range of the block.

Functionality

The mathematical function exponentation is called: The block returns the result of IN1IN2 (the value connected to IN1 is exponentiated by the value connected to IN2).

Behavior for calculation 0**0

The EXPT block returns the result 1 for the calculation 0**0 . In this case, the ENO output of EXPT is not reset to FALSE but TRUE is returned. 

Observe as well: 

  • For ANY_INT values (see under "Example for usage within ST-editor"):

    ANY_INT is...

    USINTUINTUDINTULINTSINTINTDINT or LINT (corresponds to →generic data type ANY_INT

    • If the return value exceeds the upper limit of the data type, the block returns the upper limit of the data type. In this case, the output ENO is set to value FALSE.

    • If the return value is below the lower limit of the data type, the block returns the lower limit of the data type. In this case, the output ENO is set to value FALSE as well.

Inputs, return value

 

Identifier

→Data type

Description

Inputs:

IN1

REALLREALUSINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_NUM)

1st value

IN2

REALLREALUSINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_NUM)

2nd value

Return value:

REALLREALUSINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_NUM)

 

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Internal error diagnostic for block

The block checks the return value. The output ENO of the block is set to value FALSE (or an equivalent) in the following cases:

  • The return value exceeds the upper limit of the data type. (Moreover for this case, the blocks returns the upper limit of the data type.)

  • The return value is below the lower limit of the data type. (Moreover for this case, the blocks returns the lower limit of the data type.)

Example for usage within ST-editor

The calculated values are evaluated by using the Assert block.

FUNCTION_BLOCK ExampleExpt
  VAR
   resultReal : REAL; 
   resultSint : SINT; 
  END_VAR
 
  resultReal := EXPT(IN1 := 3.0, IN2 := 4);
  Assert(resultReal = 81.0);
 
  resultSint := EXPT(IN1 := 2, IN2 := 3);
  Assert(resultSint = 8);
  
END_FUNCTION_BLOCK

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.

Examples for invalid connections

Invalid connections might occur in the following cases during a calculation using EXPT.

  • due to →overflows or →underflows

    Examples for invalid connections

    FUNCTION_BLOCK ExampleExptInvalid1
      VAR
       resultSint1, resultSint2 : SINT; 
       CheckENO1, CheckENO2 : BOOL;
      END_VAR
     
      resultSint1 := EXPT(IN1 := SINT#10, IN2 := SINT#3, ENO=>CheckENO1); (* The upper limit for SINT is '127'. '10**3' causes an overflow as '10**3' would evaluate to '1000'. *)
      Assert(resultSint1 = 127);
      Assert(CheckENO1 = FALSE);
     
      resultSint2 := EXPT(IN1 := SINT#-10, IN2 := SINT#3, ENO=>CheckENO2); (* The lower limit for SINT is '-128'. '-10**3' causes a negative overflow as '-10**3' would evaluate to '-1000'. *)
      Assert(resultSint2 = -128);
      Assert(CheckENO2 = FALSE);
     
    END_FUNCTION_BLOCK
  • if IN1 < 0 and IN2 is not an →integer

    Example for invalid connections

    FUNCTION_BLOCK ExampleExptInvalid2
      VAR
       resultRealInvalid : REAL; 
      END_VAR
     
      resultRealInvalid:= EXPT(IN1 := REAL#-25.0, IN2 := REAL#0.5);
      (* For the built-in PLC, 'resultRealInvalid' evaluates to 'NaN' in the 'Values of Variables* view. *)
      (* But this is not the case for vxWorks x86. *)
      ASSERT(NOT IS_VALID(resultRealInvalid));
     
    END_FUNCTION_BLOCK

See also "EXPT block returns a wrong value under certain target system in case of an invalid connection".